@layout('base')

@section('content')
<h1>Wiki</h1>
<form class="form-horizontal" action="{{ URL::to_route('edit_entry', array($entry->id)) }}" method="POST">
    <div class="row">
        <div class="span12">
            @if (isset($error))
            <div class="alert alert-error">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <h4>{{ Lang::line('global.error')->get() }}!</h4>
                {{ Lang::line('wiki::edit_entry.changes_not_saved')->get() }}
            </div>
            @elseif (isset($success))
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <h4>{{ Lang::line('global.success')->get() }}!</h4>
                {{ Lang::line('wiki::edit_entry.changes_saved')->get() }}
            </div>
            @endif
        </div>
    </div>
    <div class="row">
        <div class="span8 well well-large">
            <p>
                <input name="title" type="text" value="{{ $entry->title }}">
            </p>

            <p>
                <textarea name="content" class="wysiwyg">{{ $entry->content }}</textarea>
            </p>

            <p>
                <button type="submit" name="save" class="btn">
                    {{ Lang::line('global.save', array('entity' => Lang::line('wiki::global.entry')->get()))->get() }}
                </button>
                <a href="{{ URL::to_route('entry', array($entry->id)) }}" class="btn">
                    {{ Lang::line('global.cancel', array('entity' => Lang::line('wiki::global.entry')->get()))->get() }}
                </a>
            </p>
        </div>
        <div class="span3">
            <label>{{ Lang::line('wiki::global.categories')->get() }}</label>
            <select name="categories[]" data-placeholder="{{ Lang::line('wiki::edit_entry.add_categories')->get() }}"
                    class="chzn-select-create-option" multiple="multiple">
                <option value=""></option>
                @foreach ($categories as $Category)
                <option value="{{ $Category->id }}"
                {{ $Category->selected }}>{{ $Category->category }}</option>
                @endforeach
            </select>

            <label>{{ Lang::line('wiki::global.tags')->get() }}</label>
            <select name="tags[]" data-placeholder="{{ Lang::line('wiki::edit_entry.add_tags')->get() }}"
                    class="chzn-select-create-option" multiple="multiple">
                <option value=""></option>
                @foreach ($tags as $Tag)
                <option value="{{ $Tag->id }}"
                {{ $Tag->selected }}>{{ $Tag->tag }}</option>
                @endforeach
            </select>
        </div>
    </div>
</form>
@endsection
@section('scripts')
{{ HTML::script('js/jquery/chosen.min.js') }}
{{ HTML::script('bundles/wiki/js/script.js') }}
@endsection